<template>
  <div>
    姓名:
    <input type="text" v-model="name">
    <button @click="onOk">ok</button>
    <div id="name">{{ myName }}</div>
  </div>
</template>

<script>
import eventBus from '../event-bus';
export default {
  data () {
    return {
      name: eventBus.person.name,
    };
  },
  computed: {
    myName () {
      return eventBus.person.name;
    },
  },
  methods: {
    onOk () {
      eventBus.$emit('改名字', this.name);
    },
  },
}
</script>

<style scoped>

</style>